home *** CD-ROM | disk | FTP | other *** search
/ Geni@l B1 3 / Geni@l B1 3.iso / Mac_OSX / Install Flash Player 10 UB.dmg / Adobe Flash Player.pkg / Contents / Resources / ICVersionValidator.awk < prev    next >
Text File  |  2009-02-05  |  2KB  |  67 lines

  1. #
  2. # Copyright 2008 Adobe Systems Incorporated. All Rights Reserved.
  3. #
  4.  
  5. # Returns 0 if version of running system is >= kMinimumRequiredVersion
  6. # as defined below. Returns 1 if an error is encountered, or if the
  7. # version of the running system is < kMinimumRequiredVersion.
  8.  
  9. BEGIN {
  10.     # Declare & Define statics
  11.     kSuccess = 0
  12.     kError = 1
  13.     
  14.     kMinimumRequiredVersion = "10.4.0"
  15.     componentCount = split(kMinimumRequiredVersion, kMinimumRequiredVersionComponents, ".")
  16.     
  17.     # get data
  18.     getline
  19.     comparisonComponentCount = split($0, versionComponents, ".")
  20.     
  21.     # Must have at least 1 component in the version tuple.
  22.     if (comparisonComponentCount < 1) {
  23.         exit kError
  24.     }
  25.     
  26.     # This script compares the first 'n' number of components in the
  27.     # tuple, where 'n' is the number of componets in the
  28.     # minimumRequired comparison tuple. It pads out the returned value
  29.     # with zeroes as necessary.
  30.     if (comparisonComponentCount < componentCount)
  31.     {
  32.         for(i = comparisonComponentCount + 1; i <= componentCount; i++)
  33.         {
  34.             versionComponents[i] = 0
  35.         }
  36.     }
  37.     
  38.     # Compare version components piece-by-piece from left to right.
  39.     # Conditions: For each component:
  40.     #    if systemValue > minimumRequired value, exit successfully.
  41.     #    if systemValue < minimumRequired value, exit with failure.
  42.     #    if systemValue == minimumRequired value, continue to test
  43.     #        next component, unless we've tested all of the
  44.     #        returned system component values (up to and
  45.     #        including the last digit), in which case, exit successfully.
  46.     
  47.     # Note: split()-created arrays are 1-based in awk.
  48.     for (i = 1; i <= componentCount; i++)
  49.     {
  50.         currentComponentDigit = int(versionComponents[i])
  51.         if (currentComponentDigit > kMinimumRequiredVersionComponents[i]) {
  52.             exit kSuccess
  53.         }
  54.         if (currentComponentDigit < kMinimumRequiredVersionComponents[i]) {
  55.             exit kError
  56.         }
  57.         if (currentComponentDigit == kMinimumRequiredVersionComponents[i]) {
  58.             if (i == componentCount) {
  59.                 exit kSuccess
  60.             }
  61.         }
  62.     }
  63.     
  64.     # Execution should never get here based on the logic in the for-loop above. 
  65.     exit kError
  66. }
  67.